<cfcomponent name="announcementsService" output="false">

	<cffunction name="init" access="public" output="false" returntype="trac_fu.model.announcements.announcementsService">
		<cfargument name="announcementsDAO" type="trac_fu.model.announcements.announcementsDAO" required="true" />
		<cfargument name="announcementsGateway" type="trac_fu.model.announcements.announcementsGateway" required="true" />

		<cfset variables.announcementsDAO = arguments.announcementsDAO />
		<cfset variables.announcementsGateway = arguments.announcementsGateway />

		<cfreturn this/>
	</cffunction>

	<cffunction name="getannouncements" access="public" output="false" returntype="announcements">
		
		<cfset var announcements = createObject("component","trac_fu.model.announcements.announcements").init(argumentCollection=arguments) />
		<cfreturn variables.announcementsDAO.read(announcements) />
	</cffunction>

	<cffunction name="getannouncementss" access="public" output="false" returntype="query">
		<cfargument name="id" type="string" required="false" />
		<cfargument name="title" type="string" required="false" />
		<cfargument name="body" type="string" required="false" />
		<cfargument name="projectidfk" type="string" required="false" />
		<cfargument name="useridfk" type="string" required="false" />
		<cfargument name="posted" type="date" required="false" />
		
		<cfreturn variables.announcementsGateway.getByAttributes(argumentCollection=arguments) />
	</cffunction>

	<cffunction name="saveannouncements" access="public" output="false" returntype="boolean">
		<cfargument name="id" type="string" required="true" />
		<cfargument name="title" type="string" required="true" />
		<cfargument name="body" type="string" required="true" />
		<cfargument name="projectidfk" type="string" required="true" />
		<cfargument name="useridfk" type="string" required="true" />
		<cfargument name="posted" type="date" required="true" />
		
		
		<cfset var announcements = getannouncements() />
		<cfset announcements.setid(arguments.id) />
		<cfset announcements.settitle(arguments.title) />
		<cfset announcements.setbody(arguments.body) />
		<cfset announcements.setprojectidfk(arguments.projectidfk) />
		<cfset announcements.setuseridfk(arguments.useridfk) />
		<cfset announcements.setposted(arguments.posted) />
		<cfreturn variables.announcementsDAO.save(arguments.announcements) />
	</cffunction>

	<cffunction name="deleteannouncements" access="public" output="false" returntype="boolean">
		
		<cfset var announcements = createObject("component","trac_fu.model.announcements.announcements").init(argumentCollection=arguments) />
		<cfreturn variables.announcementsDAO.delete(announcements) />
	</cffunction>
</cfcomponent>